package com.yunchuang.common;

import static com.yunchuang.constant.CommonConstant.ERROR_CODE;
import static com.yunchuang.constant.CommonConstant.SUCCESS_CODE;

/**
 * 返回结果类
 *
 * @author ItJiange
 * @date 2023/10/26
 */
public class ResultUtil {
    /**
     * 返回成功数据
     * @param data
     * @return
     * @param <T>
     */
    public static <T> BaseResult <T> success(T data) {
        return new BaseResult<>(SUCCESS_CODE, "成功！", data);
    }
    /**
     * 返回成功数据
     * @param data
     * @return
     * @param <T>
     */
    public static <T> BaseResult <T> success(String message, T data) {
        return new BaseResult<>(SUCCESS_CODE, message, data);
    }

    public static BaseResult error(String message) {
        return new BaseResult(ERROR_CODE, message, null);
    }

    public static BaseResult error(BaseResult baseResult) {
        return baseResult;
    }
}
